package com.inetools.gwetons.logging.shared;

import java.util.logging.Level;
import java.util.logging.Logger;

import com.google.gwt.logging.client.SystemLogHandler;

class LoggerInitializerForTestImpl implements LoggerInitializerForTest {
	private LoggerInitializerForTestImpl() {
	}
	
	int count = 0;
	
	/**
	 * Set level of root logger to warning level. <br />
	 * Set up the following log handlers:
	 * <ul>
	 * <li>SystemLogHandler</li>
	 * <li>DevelopmentModeLogHandler</li>
	 * <li>FirebugLogHandler</li>
	 * <li>ConsoleLogHandler</li>
	 * </ul>
	 */
	@Override
	public void setupLogger() {
		if ( count++ > 0) return;
		
		Logger rootLogger = Logger.getLogger( "");
			rootLogger.setLevel( Level.WARNING);
			// Handler ------------------------------------------------------------------------
			SystemLogHandler systemLogHandler = new SystemLogHandler();
				systemLogHandler.setLevel( Level.ALL);
				rootLogger.addHandler( systemLogHandler);
			// --------------------------------------------------------------------------------
	}
	
	static final LoggerInitializerForTestImpl instance = new LoggerInitializerForTestImpl();
}